package dialogos;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashSet;
import java.util.Iterator;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import paneles.PanelProfesionales;
import peluqueria.Peluqueria;
import accesoADatos.AccesoADatos;
import datos.Profesional;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ProfeDialog extends javax.swing.JDialog {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private PanelProfesionales datosProfPane1;
	

	/**
	* Auto-generated main method to display this JDialog
	*/
	
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {

			@Override
			public void run() {
				JFrame frame= new JFrame();
				ProfeDialog ap=new ProfeDialog(frame);
				ap.setVisible(true);
				
			}
		});
	}
	
	
	public ProfeDialog(JFrame frame) {
		super(frame);
		initGUI();
	}
	
	private void initGUI() {
		try {
			this.setTitle("Agregar Profesional");
			this.setPreferredSize(new java.awt.Dimension(740, 480));
			BorderLayout thisLayout = new BorderLayout();
			getContentPane().setLayout(thisLayout);			
			{
				datosProfPane1 = new PanelProfesionales();
				getContentPane().add(datosProfPane1, BorderLayout.CENTER);
				datosProfPane1.setPreferredSize(new java.awt.Dimension(272, 473));
				datosProfPane1.getBAceptar().addMouseListener(new MouseAdapter() {
					public void mouseClicked(MouseEvent evt) {
						bAceptarMouseClicked(evt);
					}
				});
				datosProfPane1.getBCancelar().addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						bCancelarActionPerformed(evt);
					}
				});
			}

			this.setSize(740, 540);
			pack();
			this.setLocationRelativeTo(null);
			this.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void bCancelarActionPerformed(ActionEvent evt) {
		this.dispose();
	}
	
	private void bAceptarMouseClicked(MouseEvent evt) {
		Profesional p = this.datosProfPane1.getProfesional();
		AccesoADatos.getInstance().setProfesional(p);
		JOptionPane.showMessageDialog(this, "Se ha agregado el profesional "+ p);
		Peluqueria.getInstance().getCalendario().resizeTable();
		this.dispose();		
	}

}
